package it.unibo.refolding.pico;

import java.awt.Shape;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StripChartDirectionData extends AbstractDirectionData {

	public StripChartDirectionData(short[] deflection, short[] z) {
		super(deflection, z);
	}

	@Override
	public List<Shape> draw(double svgDefScale) {
		List<Shape> result = new ArrayList<>();
		for (int i = 0; i < deflection.length - 1; ++i) {
			result.add(new Line2D.Double(z[i], deflection[i] * svgDefScale, z[i + 1],
					deflection[i + 1] * svgDefScale));
		}
		return result;
	}

	@Override
	public StripChartDirectionData subRange(int from, int to) {
		return new StripChartDirectionData(
			Arrays.copyOfRange(deflection, from, to), Arrays.copyOfRange(z, from, to));
	}
}
